﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using _XNA__RunningDeath.GLO;

namespace _XNA__RunningDeath.GUI
{
    class CGUI_About : CDiaLogBox
    {
        Texture2D _texBackgroundAbout;
        Texture2D _texBtnBack;
        

        public CGUI_About(ContentManager content, GameTime gametime, SpriteBatch spritebatch):base(content,gametime,spritebatch)
        {
            if(this._content != null)
            {
                this._texBackgroundAbout = this._content.Load<Texture2D>(@"GUI/bgAbout");
                this._texBtnBack = this._content.Load<Texture2D>(@"GUI/btnBack");

                this._texBG = this._content.Load<Texture2D>(@"GUI/guiBG");
                this._dstoado = this._content.Load<Dictionary<string, Rectangle>>(@"GUI/ztoadoXMLgui");
            }
        }

        public override void Update(GameTime gameTime)
        {
            CGLOBAL.MousePrev = CGLOBAL.MouseCurrent;   //lưu trạng thái chuột vừa click
            CGLOBAL.MouseCurrent = Mouse.GetState();    // Lấy trạng thái chuột mới

            if (CGLOBAL.MouseCurrent.LeftButton == ButtonState.Pressed && CGLOBAL.MousePrev.LeftButton == ButtonState.Released)//double click
            {
                if (this._dstoado["btnBackAbout"].Contains(new Point(CGLOBAL.MouseCurrent.X, CGLOBAL.MouseCurrent.Y)))  // Contains = chứa cái gì
                {
                    CGLOBAL.soundFXbtn.Play(CThamSo.volumSound, CThamSo.pitchSound, CThamSo.panSound);
                    CGLOBAL.NextGUI = true; // chuyển đến gui
                    CGLOBAL.GUISelected = GUIenum.guiMainMenu; // chuyển đến giao diện nào
                }
            }
        }

        public override void Draw(GameTime gameTime)
        {
            this._spriteBatch.Begin();

            this._spriteBatch.Draw(this._texBG, Vector2.Zero, Color.Gray);

            this._spriteBatch.Draw(this._texBackgroundAbout, new Vector2(this._dstoado["bgAbout"].X, this._dstoado["bgAbout"].Y), Color.White);
            this._spriteBatch.Draw(this._texBtnBack, new Vector2(this._dstoado["btnBackAbout"].X, this._dstoado["btnBackAbout"].Y), Color.White);

            this._spriteBatch.End();
        }
    }


}
